﻿CREATE TABLE [dbo].[RuleCondition] (
    [Id]               INT           IDENTITY (1, 1) NOT NULL,
    [RuleId]           INT           NOT NULL,
    [FunctionId]       INT           NULL,
    [ManagedSegmentId] INT           NULL,
    [Type]             SMALLINT      NOT NULL,
    [Value]            VARCHAR (MAX) NULL,
    [ReferenceDate]    DATE          NOT NULL,
    [LastUpdate]       DATETIME      DEFAULT (getdate()) NOT NULL,
    PRIMARY KEY CLUSTERED ([Id] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF),
    FOREIGN KEY ([RuleId]) REFERENCES [dbo].[Rule] ([Id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
    FOREIGN KEY ([FunctionId]) REFERENCES [dbo].[Function] ([Id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
    FOREIGN KEY ([ManagedSegmentId]) REFERENCES [dbo].[ManagedSegment] ([Id]) ON DELETE NO ACTION ON UPDATE NO ACTION
);





